cmake_minimum_required(VERSION 3.19)
project(ChatServerMock LANGUAGES CXX)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets Protobuf HttpServer WebSockets)


message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "Checking: ${CMAKE_CURRENT_SOURCE_DIR}/resource/image/logo.png")
file(GLOB TEST_EXIST resource/image/logo.png)
message(STATUS "File GLOB result: ${TEST_EXIST}")


file(GLOB PB_FILES "./proto/*.proto")
qt_standard_project_setup()

qt_add_executable(ChatServerMock
    WIN32 MACOSX_BUNDLE
    main.cpp
    widget.cpp
    widget.h
    widget.ui
    server.h
    server.cpp
)
#qt_add_resources(ChatServerMock "resources"
#    PREFIX "/"
#    FILES resource.qrc
#)
#qt_add_resources(ChatServerMock "test"
#    PREFIX "/test"
#    FILES test.png
#)
#qt_add_resources(ChatServerMock "images"
#    PREFIX "/res"
#    FILES
#        res/logo.png
#)
qt_add_resources(ChatServerMock "images"
    FILES
        resource/image/apply_active.png
        resource/image/apply_inactive.png
        resource/image/checked.png
        resource/image/cross.png
        resource/image/defaultAvatar.png
        resource/image/file.png
        resource/image/friend_active.png
        resource/image/friend_inactive.png
        resource/image/groupAvatar.png
        resource/image/history.png
        resource/image/image.png
        resource/image/logo.png
        resource/image/modify.png
        resource/image/more.png
        resource/image/search.png
        resource/image/session_active.png
        resource/image/session_inactive.png
        resource/image/sound.png
        resource/image/sound_active.png
        resource/image/submit.png
        resource/image/unchecked.png

)
qt_add_resources(ChatServerMock "files"
    FILES
        resource/file/testFile.txt

)
qt_add_resources(ChatServerMock "speeches"
    FILES
        resource/speech/tmpRecord.pcm

)
qt_add_protobuf(ChatServerMock PROTO_FILES ${PB_FILES})
target_link_libraries(ChatServerMock
    PRIVATE
        Qt::Core
        Qt::Widgets
        Qt6::Protobuf
        Qt6::HttpServer
        Qt6::WebSockets
)

include(GNUInstallDirs)

install(TARGETS ChatServerMock
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET ChatServerMock
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
